home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Event;
- import java.awt.Point;
- import java.io.DataInputStream;
-
- public class CMoveAction extends CDisplayAction {
- final int WAIT = 1;
- final int NOTIFY = 32;
- final int PLAY_COUNT = 1048576;
- final byte FOLLOW_PATH;
- final byte POINT_TO_POINT = 1;
- final byte MOVE_TO = 3;
- protected short m_byType;
- protected int m_nFlags;
- protected CVarOrValue m_nMoveTime = new CVarOrValue();
- protected String m_sMoveObject;
- protected CPolyline m_plPath = new CPolyline();
- protected CVarOrValue m_Base = new CVarOrValue();
- protected CVarOrValue m_Position = new CVarOrValue();
- protected int m_nPlayCount;
- private CDrawObj m_pDrawObj;
- private Point m_ptCurrent;
- private int m_nCurrentPt;
- private int m_nDistance;
- private int m_nStepLength;
- private long m_lStepTime;
- private int m_nBezierPt;
- private int m_nBezierSteps;
- private int m_nLoopCounter;
- private long m_lTimeRemaining;
- private long m_lMoveStartTime;
- private long m_lNextStepTime;
- private double m_dDistanceRemaining;
- private short m_byActualType;
-
- boolean IsActive() {
- return this.m_lStepTime != 0L;
- }
-
- boolean DoAction() {
- this.FreeObject();
- this.m_lMoveStartTime = -1L;
- ((CDisplayAction)this).SetDrawRect(this.m_plPath.GetBoundingRect());
- CDrawObj var1 = Globals.thePresView.AddDrawObject((CIconObject)this, 1538, false);
- String var2 = Utils.InsertVariablesInString(this.m_sMoveObject);
- this.m_pDrawObj = Globals.thePresView.FindDrawObject(var2);
- if (this.m_pDrawObj != null) {
- switch (this.m_byType) {
- case 0:
- case 1:
- if (this.m_plPath.npoints >= 2) {
- this.m_lStepTime = 1L;
- this.m_dDistanceRemaining = this.m_plPath.GetPathLength();
- this.m_lTimeRemaining = (long)(10 * this.m_nMoveTime.GetValue());
- if (var1 != null) {
- Globals.theAnimThread.AddAnimObject(var1);
- }
- } else {
- System.out.println("Too few points specified for FOLLOW_PATH or POINT_TO_POINT: " + this.m_plPath.npoints);
- }
-
- this.m_byActualType = this.m_byType;
- case 2:
- default:
- break;
- case 3:
- this.m_ptCurrent.x = this.m_pDrawObj.GetDrawRect().x;
- this.m_ptCurrent.y = this.m_pDrawObj.GetDrawRect().y;
- if ((this.m_nFlags & 'ΦÇÇ') == 0) {
- Point var10000 = this.m_ptCurrent;
- var10000.x += this.m_pDrawObj.GetDrawRect().width / 2;
- var10000 = this.m_ptCurrent;
- var10000.y += this.m_pDrawObj.GetDrawRect().height / 2;
- }
-
- Point var3 = new Point(this.m_Base.GetValue(), this.m_Position.GetValue());
- if (var3 != null && !var3.equals(this.m_ptCurrent)) {
- if (this.m_nMoveTime.GetValue() == 0) {
- this.m_pDrawObj.MoveTo(var3, true, (this.m_nFlags & 'ΦÇÇ') != 0);
- this.m_lStepTime = 0L;
- if ((this.m_nFlags & 32) != 0) {
- Event var4 = new Event(Globals.thePresView, 2029, (Object)null);
- var4.modifiers = 2011;
- Globals.thePresView.postEvent(var4);
- }
- } else {
- this.m_lStepTime = 1L;
- this.m_byActualType = 0;
- this.m_nCurrentPt = 0;
- int[] var7 = new int[]{this.m_ptCurrent.x, var3.x};
- int[] var5 = new int[]{this.m_ptCurrent.y, var3.y};
- this.m_plPath = new CPolyline(var7, var5, 2);
- this.m_dDistanceRemaining = this.m_plPath.GetPathLength();
- this.m_lTimeRemaining = (long)(10 * this.m_nMoveTime.GetValue());
- if (var1 != null) {
- Globals.theAnimThread.AddAnimObject(var1);
- }
- }
- } else {
- this.m_lStepTime = 0L;
- }
- }
- } else {
- this.m_lStepTime = 0L;
- if ((this.m_nFlags & 32) != 0) {
- Event var6 = new Event(Globals.thePresView, 2029, (Object)null);
- var6.modifiers = 2011;
- Globals.thePresView.postEvent(var6);
- }
- }
-
- return true;
- }
-
- boolean LoadFromFile(DataInputStream var1) {
- this.m_byType = FileLoad.ReadCPlusByte(var1);
- this.m_nFlags = FileLoad.ReadCPlusUInt(var1);
- this.m_sMoveObject = FileLoad.ReadCString(var1);
- this.m_nPlayCount = FileLoad.ReadCPlusInt(var1);
- this.m_nMoveTime.LoadFromFile(var1);
- this.m_plPath.LoadFromFile(var1);
- this.m_Base.LoadFromFile(var1);
- CVarOrValue var2 = new CVarOrValue();
- var2.LoadFromFile(var1);
- this.m_Position.LoadFromFile(var1);
- return super.LoadFromFile(var1);
- }
-
- public CMoveAction() {
- ((CDisplayAction)this).SetZOrder((short)2);
- }
-
- void FreeObject() {
- this.m_pDrawObj = null;
- this.m_ptCurrent = new Point(0, 0);
- this.m_nCurrentPt = 0;
- this.m_nDistance = 0;
- this.m_nStepLength = 0;
- this.m_lStepTime = 0L;
- this.m_nBezierPt = 0;
- this.m_nBezierSteps = 0;
- this.m_nLoopCounter = 0;
- this.m_lTimeRemaining = 0L;
- this.m_lNextStepTime = 0L;
- this.m_dDistanceRemaining = (double)0.0F;
- this.m_byActualType = 0;
- }
-
- boolean DoPointToPoint(long var1) {
- boolean var3 = true;
- this.m_lStepTime = (long)(this.m_nMoveTime.GetValue() * 10 / this.m_plPath.npoints);
- this.m_lNextStepTime = Globals.theAnimThread.GetLoopStartTime() + this.m_lStepTime;
- if (this.m_nCurrentPt < this.m_plPath.npoints) {
- this.m_ptCurrent.x = this.m_plPath.xpoints[this.m_nCurrentPt];
- this.m_ptCurrent.y = this.m_plPath.ypoints[this.m_nCurrentPt];
- this.m_pDrawObj.MoveTo(this.m_ptCurrent, true, (this.m_nFlags & 'ΦÇÇ') != 0);
- ++this.m_nCurrentPt;
- } else {
- ++this.m_nLoopCounter;
- if ((this.m_nFlags & 1048576) != 0 && this.m_nLoopCounter >= this.m_nPlayCount) {
- this.m_lStepTime = 0L;
- if ((this.m_nFlags & 32) != 0) {
- Event var4 = new Event(Globals.thePresView, 2029, (Object)null);
- var4.modifiers = 2011;
- Globals.thePresView.postEvent(var4);
- }
-
- var3 = false;
- } else {
- this.m_nCurrentPt = 0;
- this.m_ptCurrent.x = this.m_plPath.xpoints[this.m_nCurrentPt];
- this.m_ptCurrent.y = this.m_plPath.ypoints[this.m_nCurrentPt];
- this.m_pDrawObj.MoveTo(this.m_ptCurrent, true, (this.m_nFlags & 'ΦÇÇ') != 0);
- ++this.m_nCurrentPt;
- }
- }
-
- return var3;
- }
-
- boolean DoFollowPath(long var1) {
- boolean var3 = true;
- if (var1 == -1L || this.m_lMoveStartTime == -1L) {
- this.m_lMoveStartTime = System.currentTimeMillis();
- var1 = Math.max(var1, 1L);
- }
-
- if (var1 == 0L) {
- var1 = 1L;
- }
-
- int var4 = Math.min(Math.max((int)(this.m_lTimeRemaining / var1), 1), (int)this.m_dDistanceRemaining);
- System.currentTimeMillis();
- if (var4 == 0) {
- var4 = 1;
- }
-
- this.m_nStepLength = Math.max((int)(this.m_dDistanceRemaining / (double)var4), 1);
- System.currentTimeMillis();
- this.m_lStepTime = Math.max(this.m_lTimeRemaining / (long)var4, 1L);
- this.m_lNextStepTime = Globals.theAnimThread.GetLoopStartTime() + this.m_lStepTime;
- this.m_dDistanceRemaining -= (double)this.m_nStepLength;
- this.m_lTimeRemaining = this.m_lMoveStartTime + (long)(this.m_nMoveTime.GetValue() * 10) - System.currentTimeMillis();
- this.m_nDistance += this.m_nStepLength;
- new CPathData();
- CPathData var5 = this.m_plPath.GetPointOnPath(this.m_nDistance, this.m_nCurrentPt, this.m_nBezierPt, this.m_nBezierSteps, this.m_nStepLength);
- this.m_nCurrentPt = var5.nCurrentPt;
- this.m_nDistance = var5.nDistance;
- if ((this.m_nFlags & 1048576) != 0) {
- if (this.m_nPlayCount == 1) {
- if (var5.nCurrentPt >= this.m_plPath.npoints - 1 || var5.bLooped) {
- var5.ptNew.move(this.m_plPath.xpoints[this.m_plPath.npoints - 1], this.m_plPath.ypoints[this.m_plPath.npoints - 1]);
- this.m_lStepTime = 0L;
- if ((this.m_nFlags & 32) != 0) {
- Event var6 = new Event(Globals.thePresView, 2029, (Object)null);
- var6.modifiers = 2011;
- Globals.thePresView.postEvent(var6);
- }
-
- var3 = false;
- }
- } else if (var5.bLooped) {
- ++this.m_nLoopCounter;
- if (this.m_nLoopCounter >= this.m_nPlayCount) {
- var5.ptNew.move(this.m_plPath.xpoints[this.m_plPath.npoints - 1], this.m_plPath.ypoints[this.m_plPath.npoints - 1]);
- this.m_lStepTime = 0L;
- if ((this.m_nFlags & 32) != 0) {
- Event var7 = new Event(Globals.thePresView, 2029, (Object)null);
- var7.modifiers = 2011;
- Globals.thePresView.postEvent(var7);
- }
-
- var3 = false;
- } else {
- this.m_lMoveStartTime = System.currentTimeMillis();
- this.m_dDistanceRemaining = this.m_plPath.GetPathLength() - (double)this.m_nDistance;
- this.m_lTimeRemaining = (long)(10 * this.m_nMoveTime.GetValue());
- }
- }
- } else if (var5.bLooped) {
- this.m_lMoveStartTime = System.currentTimeMillis();
- this.m_dDistanceRemaining = this.m_plPath.GetPathLength() - (double)this.m_nDistance;
- this.m_lTimeRemaining = (long)(10 * this.m_nMoveTime.GetValue());
- }
-
- if (this.m_pDrawObj != null) {
- this.m_pDrawObj.MoveTo(var5.ptNew, false, (this.m_nFlags & 'ΦÇÇ') != 0);
- }
-
- return var3;
- }
-
- boolean DoAnimation(CRect var1, long var2) {
- boolean var4 = this.m_lStepTime != 0L;
- if (this.m_lStepTime != 0L && this.m_lNextStepTime <= System.currentTimeMillis()) {
- switch (this.m_byActualType) {
- case 0:
- var4 = this.DoFollowPath(var2);
- break;
- case 1:
- var4 = this.DoPointToPoint(var2);
- break;
- default:
- System.out.println("Invalid move type requested: " + this.m_byActualType);
- }
- }
-
- return var4;
- }
-
- boolean RequiresWait() {
- return (this.m_nFlags & 1) != 0;
- }
-
- CPolyline GetActualPolyline() {
- return this.m_plPath;
- }
-
- CDrawObj GetMoveObject() {
- return this.m_pDrawObj;
- }
- }
-